$(function () {
    var adminloginurl = '/admin/doadminlogin';
    $('#submit').click(function() {
        var blogadmin = {};

        blogadmin.username = $('#username').val();
        blogadmin.password = $('#password').val();

        var formData = new FormData();
        var verifyCodeActual = $('#j_captcha').val();
        if (!verifyCodeActual) {
            $('.input_captcha').click();
            return;
        }
        formData.append("verifyCodeActual", verifyCodeActual);
        formData.append('adminStr', JSON.stringify(blogadmin));
        // var verifyCodeActual = $('#j_captcha').val();
        // if (!verifyCodeActual) {
        // 	$.toast('请输入验证码！');
        // 	return;
        // }
        // formData.append("verifyCodeActual", verifyCodeActual);
        $.ajax({
            // url : (isEdit? editShopUrl:addShopUrl),
            url : adminloginurl,
            type : 'POST',
            // contentType: "application/x-www-form-urlencoded; charset=utf-8",
            data : formData,
            contentType : false,
            processData : false,
            cache : false,
            success : function(data) {
                if (data.success) {
                    $('.loginsuccess').click();
                    window.setTimeout("window.location='/admin/index'",1500);
                    // if (isEdit){
                    // 	$('#captcha_img').click();
                    // } else{
                    // 	window.location.href="/shopadmin/shoplist";
                    // }
                } else {
                    $('.fail-message').html(data.errMsg);
                    $('.loginfail').click();
                }
            }
        });
    });
});